from django.db import models

# Create your models here.

# 创建员工表


# 创建部门表
class department(models.Model):
    name=models.CharField(max_length=50,verbose_name='名称')
    count=models.IntegerField(verbose_name='总数',default=0)
    # 定义表名
    class Meta:
        db_table='department'

class User(models.Model):
    username=models.CharField(max_length=50,verbose_name='用户名')
    password=models.CharField(max_length=300,verbose_name='密码')
    authority=models.IntegerField(default=2) # 1.超级权限 2.普通权限
    dep=models.ForeignKey(department,on_delete=models.CASCADE)
    # 定义表名
    class Meta:
        db_table='user'

#   创建图书分类表
class Bcate(models.Model):
    classname=models.CharField(max_length=50,verbose_name='分类名称')
    count=models.IntegerField(verbose_name='总数')
    # 定义表名
    class Meta:
        db_table='bcate'

#   创建图书表
class Book(models.Model):
    name=models.CharField(max_length=50,verbose_name='名称')
    price=models.DecimalField(max_digits=7,decimal_places=2,verbose_name='价格')
    bcate=models.ForeignKey(Bcate,on_delete=models.CASCADE)
    # 定义表名
    class Meta:
        db_table='book'